from .operation import *

operation_code_dict = { 
    0x01 : CreateConstantString,
    0x05 : PlaceBlockWithBlockStates1,
    0x06 : AddInt16ZValue0,
    0x07 : PlaceBlock,
    0x08 : AddZValue0,
    0x09 : NOP,
    0x0c : AddInt32ZValue0,
    0x0d : PlaceBlockWithBlockStates2,
    0x0e : AddXValue,
    0x0f : SubtractXValue,
    0x10 : AddYValue,
    0x11 : SubtractYValue,
    0x12 : AddZValue,
    0x13 : SubtractZValue,
    0x14 : AddInt16XValue,
    0x15 : AddInt32XValue,
    0x16 : AddInt16YValue,
    0x17 : AddInt32YValue,
    0x18 : AddInt16ZValue,
    0x19 : AddInt32ZValue,
    0x1a : SetCommandBlockData,
    0x1b : PlaceBlockWithCommandBlockData,
    0x1c : AddInt8XValue,
    0x1d : AddInt8YValue,
    0x1e : AddInt8ZValue,
    0x1f : UseRuntimeIDPool,
    0x20 : PlaceRuntimeBlock,
    0x21 : placeBlockWithRuntimeId,
    0x22 : PlaceRuntimeBlockWithCommandBlockData,
    0x23 : PlaceRuntimeBlockWithCommandBlockDataAndUint32RuntimeID,
    0x24 : PlaceCommandBlockWithCommandBlockData,
    0x25 : PlaceRuntimeBlockWithChestData,
    0x26 : PlaceRuntimeBlockWithChestDataAndUint32RuntimeID,
    0x27 : AssignDebugData,
    0x28 : PlaceBlockWithChestData,
    0x29 : PlaceBlockWithNBTData,
    0x58 : Terminate,
}

def get_operation(code:int) -> Union[
    CreateConstantString,
    PlaceBlockWithBlockStates1,
    AddInt16ZValue0,
    PlaceBlock,
    AddZValue0,
    NOP,
    AddInt32ZValue0,
    PlaceBlockWithBlockStates2,
    AddXValue,
    SubtractXValue,
    AddYValue,
    SubtractYValue,
    AddZValue,
    SubtractZValue,
    AddInt16XValue,
    AddInt32XValue,
    AddInt16YValue,
    AddInt32YValue,
    AddInt16ZValue,
    AddInt32ZValue,
    SetCommandBlockData,
    PlaceBlockWithCommandBlockData,
    AddInt8XValue,
    AddInt8YValue,
    AddInt8ZValue,
    UseRuntimeIDPool,
    PlaceRuntimeBlock,
    placeBlockWithRuntimeId,
    PlaceRuntimeBlockWithCommandBlockData,
    PlaceRuntimeBlockWithCommandBlockDataAndUint32RuntimeID,
    PlaceCommandBlockWithCommandBlockData,
    PlaceRuntimeBlockWithChestData,
    PlaceRuntimeBlockWithChestDataAndUint32RuntimeID,
    AssignDebugData,
    PlaceBlockWithChestData,
    PlaceBlockWithNBTData,
    Terminate] : 
    if isinstance(code,bytes) : code = code[0]
    return operation_code_dict[code]


if __name__ == "__main__" :
    for i in operation_code_dict.values() : print(i.__name__ + ",")

